import { defineStore } from 'pinia'
import exhibition from '../../api/exhibition'
import {  classificationCategory } from '../../utils/trueType'

export const useAddExhibitionStore = defineStore('addExhibition', {
  state: () => ({
    loading: false,
    error: null,
    isOpen: false,
    categoryList: [
    ] as classificationCategory[],
  }),
  
  actions: {
    // 添加展览
    async addExhibition(exhibitionData) {
      this.loading = true
      this.error = null
      
      try {
        // 这里应该调用API接口，但目前API接口尚未实现
        // 模拟API调用成功
        console.log('添加展览数据:', exhibitionData)
        exhibition.addExhibition(exhibitionData).catch(err => {
          console.log(err)
        })
        // 实际项目中，应该使用以下代码调用API
        // const response = await exhibition.addExhibition(exhibitionData)
        // return response.data
        
        // 模拟成功响应
        
      } catch (error) {
        this.error = error.message || '添加展览失败'
        throw error
      } finally {
        this.loading = false
      }
    },
    setIsOpen(value) {
      this.isOpen = value
    }
  }
})